/*
 * Copyright 2011 Potix Corporation. All Rights Reserved.
 * 
 * Licensed under the GNU GENERAL PUBLIC LICENSE Version 3 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at:
 * 
 * http://www.gnu.org/licenses/gpl-3.0.txt
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 * implied. See the License for the specific language governing 
 * permissions and limitations under the License.
 */
package org.zkoss.xpage.core.web;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;

import org.zkoss.xpage.core.util.Log;
import org.zkoss.zk.ui.http.DHtmlLayoutServlet;
/**
 * wrap {@link DHtmlLayoutServlet}
 * @author Dennis Chen
 *
 */
public class LayoutServlet extends DHtmlLayoutServlet {
	private static final long serialVersionUID = 1L;
	
	public void init(final ServletConfig config) throws ServletException {
		Log.log(this,"init::" + this+",context = "+config.getServletContext());
		ClassLoader cl = Thread.currentThread().getContextClassLoader();
		try {
			Thread.currentThread().setContextClassLoader(LayoutServlet.class.getClassLoader());
			super.init(config);
		}catch(Exception x){
			Log.error(this,x.getMessage(),x);
			throw new ServletException(x.getMessage(),x);
		}finally{
			Thread.currentThread().setContextClassLoader(cl);
		}
		Log.log(this,"init end::" + this);
	}

}
